﻿window.onload = PageLoad;
var program_id2 = "DELIVERY_TERM_DESC.aspx";
var _DialogWidth2 = "350px";
var _DialogHeight2 = "150px";
var dialogStr2 = "dialogWidth="+_DialogWidth2+";dialogHeight="+_DialogHeight2+";center=yes;border=thin;help=no;status=no;resizable=no;toolbar=no;location=no;title=no";

function PageLoad()
{
	try 
	{	
	
		/*if(document.all.drpDELIVERY_TERM != undefined)
		{
			if (document.all.drpDELIVERY_TERM.value=="FOB_Seaport")
			{
				document.all.lblSEAPORT.style.display=""; 
				document.all.txtSEAPORT.style.display=""; 
			}
			else
			{	
				document.all.lblSEAPORT.style.display="none"; 
				document.all.txtSEAPORT.style.display="none"; 
			}
		}*/
	
	}	
	catch (e)
    {
       alert(e.Message);
    }
    finally
    {
        
    }
	
}

/*  JOE 新增 Function 自動帶出含稅價格   */

function AD_PRICE_OnClick()
{

	//alert((0.5099 + 0.049).toFixed(4)); 
	//alert((1 - 0.9999).toFixed(4)); 
	//alert((0.5589 * 10000).toFixed(4)); 

    var result = $("#txtADVISED_PRICE1").val()* 1.05 ;
	if(result!=undefined)
	{
	  
	     var num7 = new Number(result);
	    // num7 = num7.toFixed(3) 
	    num7 = Math.round(num7)
	    $("#txtADVISED_PRICE_TAX1").val(num7);
	  
	  
	  
	   // var num7 = new Number(result);
	    //num7 = num7.toFixed(3) 
		//document.all.txtADVISED_PRICE_TAX1.value= num7;
	}		
}









function DialogBtnSave_OnClick()
{  
    try
    {
		$("#lblSUPPLY_PRICE_ERR").text("");
		$("#lblMINNUM_QTY_ERR").text("");
		$("#lblDELIVERY_TERM_ERR").text("");
		$("#lblQUOTATION_VALID_DATE_ERR").text("");
		$("#lblPAYMENT_TERM_NO_ERR").text("");
		
    	//存檔檢核
		if ($("#txtSUPPLY_PRICE1").val() != "")
    	{
		    if (isNaN($("#txtSUPPLY_PRICE1").val()))
    		{
		        $("#lblSUPPLY_PRICE_ERR").text(GetMessageByID("MSG024").text);
    		}
    	}
    	else
    	{
		    $("#lblSUPPLY_PRICE_ERR").text(GetMessageByID("MSG019").text);
    	}
    	
		if ($("#txtMINNUM_QTY1").val() != "")
    	{
		    if (isNaN($("#txtMINNUM_QTY1").val()))
    		{
		        $("#lblMINNUM_QTY_ERR").text(GetMessageByID("MSG024").text);
    		}
    	}
    	else
    	{
		    $("#lblMINNUM_QTY_ERR").text(GetMessageByID("MSG019").text);
    	}
    	
		if ($("#drpPAYMENT_TERM_NO").val() == "")
    	{
		    $("#lblPAYMENT_TERM_NO_ERR").text(GetMessageByID("MSG019").text);
    	}
    	
    /*	if(document.all.drpDELIVERY_TERM.value=="")
    	{
    		document.all.lblDELIVERY_TERM_ERR.innerText=GetMessageByID("MSG019").text;
    	}
    	*/
		if ($("#txtQUOTATION_VALID_DATE").val() != "")
    	{
    		
    		/*TMP MARK BY JOE 1102 */
    		
    	/*	if(!isDate(document.all.txtQUOTATION_VALID_DATE.value))
    		{
				document.all.lblQUOTATION_VALID_DATE_ERR.innerText=GetMessageByID("MSG021").text;
			}
			else
			{
				var ServerDate=getServerInfoByClient("date");
				if(document.all.txtQUOTATION_VALID_DATE.value < ServerDate)
				{
					document.all.lblQUOTATION_VALID_DATE_ERR.innerText=GetMessageByID("MSG062").text;
				}
			}
			
		*/	
			
    	}
    	else
    	{
		    $("#lblQUOTATION_VALID_DATE_ERR").text(GetMessageByID("MSG019").text);
    	}
    	
		
		
		if ($("#lblSUPPLY_PRICE_ERR").text() == "" && $("#lblMINNUM_QTY_ERR").text() == "" && $("#lblDELIVERY_TERM_ERR").text()== "" && $("#lblQUOTATION_VALID_DATE_ERR").text() == "" && $("#lblPAYMENT_TERM_NO_ERR").text() == "")
		{
			return true;
		}
		else
		{
			alert(GetMessageByID("MSG020").text);
			return false;
		}
		
		
    }
	catch (e)
	{
        alert(e.Message);
        return false;
	}
	finally
	{
	
	}
}

function DialogBtnExit_OnClick()
{
	this.close();
}

function DELIVERY_TERM()
{
    if ($("#drpDELIVERY_TERM").val()=="FOB_Seaport")
	{
		$("#lblSEAPORT").css("display", "");
		$("#txtSEAPORT").css("display", "");
	}
	else
	{	
		$("#lblSEAPORT").css("display", "none");
		$("#txtSEAPORT").css("display", "none");
	}
}

function DialogBtnDEL_OnClick()
{
 
	    if(confirm(GetMessageByID("MSG064").text))
	    {
            return true;
	    }
	    else {
	        return false;
	    }
}

function DELIVERY_TERM_DESC()
{
	var result = window.showModalDialog(program_id2 , '', dialogStr2, true);
	if(result!=undefined)
	{
	    $("#txtDELIVERY_TERM").val(result)
	}
		
}